<?php
class Test extends CWidget {
    public $content = '';
    public $txt = '';

    public function __construct($content, $txt='') {
        parent::__construct();

        $this->content = $content;
        $this->txt = $txt;
    }

    public function run() {
        echo $this->txt ? $this->txt : '';
        /** Start Widget **/
        $this->beginWidget('zii.widgets.jui.CJuiDialog',array(
            'id'=>'dialog-animation',
            'options'=>array(
                'title'=>'Dialog box - Animation',
                'autoOpen'=>false,
                'show'=>array(
                    'effect'=>'blind',
                    'duration'=>1000,
                ),
                'hide'=>array(
                    'effect'=>'explode',
                    'duration'=>500,
                ),
                'width' => 'auto'
            ),
        ));
        echo $this->content;
        $this->endWidget('zii.widgets.jui.CJuiDialog');
        /** End Widget **/
        echo CHtml::button('Open Dialog', array(
            'onclick'=>'$("#dialog-animation").dialog("open"); return false;',
        ));


        $this->registerFile();
    }

    public function registerFile() {
        $assets = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . '/assets');
        $cs = Yii::app()->getClientScript();

        $cs->registerCssFile($assets . '/prism.css');
        $cs->registerScriptFile($assets . '/prism.js');
    }
}